Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress FieldDoesNotExist raised from attribute on class definition #1329

Merged
merged 1 commit into from
Jan 23, 2023

Conversation

flaeppe
Copy link
Member

@flaeppe flaeppe commented Jan 22, 2023

I have made things!

If we've found an attribute on a model class that from all we can see appears to be a field, but Django still raises FieldDoesNotExist we'll suppress it.

This can appear if one uses the (undocumented) Field(name=..., ...) argument.

Related issues

Closes #1261

If we've found an attribute on a model class that from all we can see
appears to be a field, but Django still raises `FieldDoesNotExist` we'll
suppress it.

This can appear if one uses the (undocumented) `Field(name=..., ...)`
argument.
Copy link
Collaborator

@intgr intgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is great! The explanation seems sound. I tried and this makes mypy 0.991 upgrade work without removing CI testing with old Django versions (#1260).

How on Earth this issue was related to mypy version remains a mystery to me.

@flaeppe
Copy link
Member Author

flaeppe commented Jan 23, 2023

How on Earth this issue was related to mypy version remains a mystery to me.

If I was to have a guess, I would suspect it has to do with that mypy's plugin system calls our hooks at certain times. So in the case of 0.991 it might be that a hook is triggered for a case that isn't in 0.982. Discovering this uncovered case.

@intgr intgr merged commit 34c2426 into typeddjango:master Jan 23, 2023
@flaeppe flaeppe deleted the fix/renamed-model-field branch January 23, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Plugin regression with mypy 0.99x: FieldDoesNotExist
2 participants